<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />

<link rel="stylesheet" href="${pageContext.request.contextPath}/lib/zTree/v3/css/zTreeStyle/metro.css" type="text/css">

<title>资源管理</title>
</head>


<body class="pos-r">
<div class="pos-a" style="width:300px;left:0;top:0; bottom:0; height:100%; border-right:1px solid #e5e5e5; background-color:#f5f5f5; overflow:auto;">
	<ul id="tree_resource" class="ztree"></ul>
</div>

<div id="rMenu">  
    <a href="#" class="list-group-item" onclick="addResource();">添加资源</a>  
</div> 

<div style="margin-left:300px;">
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 管理员管理 <span class="c-gray en">&gt;</span>资源列表<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
	<div class="text-c"> 
		<select id="pid" name="pid" style="width:250px" class="input-text">
			<option value="">请选择所属上级</option>
			<c:forEach var="bean" items="${beanList}">
				<option value="${bean.id}">${bean.name}</option>
			</c:forEach>
		</select>
		<input type="text" class="input-text" style="width:250px" placeholder="输入资源名称" id="name" name="name">
		<button type="submit" class="btn btn-success radius" id="btn-advanced-search" name=""><i class="Hui-iconfont">&#xe665;</i> 搜管资源</button>
	</div>
	<div class="cl pd-5 bg-1 bk-gray mt-20"> <span class="l">
	<a href="javascript:void(0);" onclick="data_edit('添加资源','initAddUpdateSysResourcePage','500','550')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加资源</a></span> 
	<span class="r">共有数据：<strong id="total">0</strong> 条</span> </div>
	<div class="mt-20">
	 <div class="span12" id="div-table-container">
	<table class="table table-border table-bordered table-hover table-bg table-sort" id="table-user">
		<thead>
			<tr class="text-c">
				<th width="25"><input type="checkbox" name="" value=""></th>
						<th width="100">所属上级</th>
						<th width="100">名称</th>
						<th width="100">类型</th>
						<th width="100">菜单类型</th>
						<th width="100">权限值</th>
						<th width="100">路径</th>
						<th width="100">图标</th>
						<th width="100">状态</th>
						<th width="100">序号</th>
						<th width="100">创建人</th>
						<th width="100">创建时间</th>
						<th width="100">操作</th>
					
			</tr>
		</thead>
		<tbody>
		</tbody>
	</table>
	</div>
	</div>
</div>
</div>
<script type="text/javascript" src="${pageContext.request.contextPath}/lib/zTree/v3/js/jquery.ztree.all-3.5.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/page/sysconfig/sysResourceMgr.js"></script>
<style type="text/css">
    div#rMenu {position:absolute; 
    visibility:hidden; top:0;
     text-align: left;
     padding:4px;
    }  
    div#rMenu a{
    	border-radius:5px;
    	display:block; 
    	margin-top:2px; 
        padding: 3px 15px 3px 15px;  
        background-color:#cad4e6;  
        vertical-align:middle;  
    }  
</style> 

<script type="text/javascript">
var zTreeObj;
var rMenu = $("#rMenu");
function zTreeOnAsyncSuccess(event, treeId, treeNode, msg) {
	zTreeObj.expandAll(true);
};
//在ztree上的右击事件  
function zTreeOnRightClick(event, treeId, treeNode) {  
    if (!treeNode && event.target.tagName.toLowerCase() != "button" && $(event.target).parents("a").length == 0) {  
        showRMenu("root", event.clientX, event.clientY);  
    } else if (treeNode && !treeNode.noR) {  
        showRMenu("node", event.clientX, event.clientY);  
    }  
}  
//显示右键菜单  
function showRMenu(type, x, y) {  
    $("#rMenu ul").show();  
    rMenu.css({"top":y+"px", "left":x+"px", "visibility":"visible"}); //设置右键菜单的位置、可见  
    $("body").bind("mousedown", onBodyMouseDown);  
}  
//隐藏右键菜单  
function hideRMenu() {  
    if (rMenu) rMenu.css({"visibility": "hidden"}); //设置右键菜单不可见  
    $("body").unbind("mousedown", onBodyMouseDown);  
}  
//鼠标按下事件  
function onBodyMouseDown(event){  
    if (!(event.target.id == "rMenu" || $(event.target).parents("#rMenu").length>0)) {  
        rMenu.css({"visibility" : "hidden"});  
    }  
}  

//选中节点事件
function zTreeOnClick(event, treeId, treeNode){
	//刷新右侧的列表信息
	$("#pid").val(treeNode.id);
	refulsh();
}

var setting = {
	async: {
		enable: true,
		type: "post",
		url: $("#hiddenpath").val()+"/sysresource/queryObjectList",
		autoParam: []
	},
	view: {
		dblClickExpand: false,
		showLine: false,
		selectedMulti: false
	},
	data: {
		simpleData: {
			enable:true,
			idKey: "id",
			pIdKey: "pid",
			rootPId: "0"
		}
	},
	
	callback: {
		onAsyncSuccess: zTreeOnAsyncSuccess,
		onRightClick: zTreeOnRightClick,
		onClick: zTreeOnClick,
	}
};



		
$(document).ready(function(){
	zTreeObj = $.fn.zTree.init($("#tree_resource"), setting);
});

function addResource(){
	var nodes = zTreeObj.getSelectedNodes();
	if(nodes==null || nodes == "" || nodes.length==0){
		layer.alert("请先选中节点!");
		return false;
	}
	var departid = nodes[0].id;
	var departName = nodes[0].name;
	data_edit('添加资源','initAddUpdateSysResourcePage?pid='+departid,'500','550')
}

</script>

</body>
</html>

